<%@page import="java.sql.Date"%>
<%@page import="java.util.*"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" import="java.util.*" 
	pageEncoding="utf-8"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>My JSP 'add_user_do.jsp' starting page</title>

<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

</head>

<body>
	<%
		request.setCharacterEncoding("utf-8");
	%>
	<jsp:useBean id="data" class="start.fly.test.database.databaseTool"
		scope="page" />
		
	<%
		
		int CardNumber = Integer.parseInt(request.getParameter("CardNumber"));
		String CardPassword = request.getParameter("CardPassword");
		float Money = Float.parseFloat(request.getParameter("Money"));
		int Point = Integer.parseInt(request.getParameter("Point"));
		
		//获取有效日期
		String stringDate = request.getParameter("TimeOutDate");
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		java.util.Date date=sdf.parse(stringDate);  
		java.sql.Date TimeOutDate = new java.sql.Date(date.getTime());
		
		int status = 0;
		int isUse = 0;
		int isBuy = 0;
		
		String statusString = request.getParameter("status");
		String isUseString = request.getParameter("isUse");
		String isBuyString = request.getParameter("isBuy");
		
		if(statusString == "lock_yes"){
			status = 1;
		}else{
			status = 0;
		}
		
		if(isUseString == "use_yes"){
			isUse = 1;
		}else{
			isUse = 0;
		}
		
		if(isBuyString == "buy_yes"){
			isBuy = 1;
		}else{
			isBuy = 0;
		}
		
		//System.out.println("Message:"+ProductID+","+Version+","+PType+","+Content+","+URL_1);
		

		boolean isInsert = data.insertToClickCard(CardNumber, CardPassword,
				Money, Point, TimeOutDate, status, isUse, isBuy);
		
		if (isInsert) {
			out.print("<script>alert('增加点卡成功');document.location='integralCardManage.jsp'</script>");
		} else {
			out.print("<script>alert('增加点卡失败');document.location='integralCardManage.jsp'</script>");
		}
	%>
</body>
</html>
